package com.rt.gptnext.common.utils.json;

import cn.hutool.core.util.ArrayUtil;
import com.alibaba.fastjson2.filter.ValueFilter;

/**
 * @author gaoyiyang
 **/
public class MultipleValueFilter implements ValueFilter {
    private final ValueFilter[] filters;

    public MultipleValueFilter(ValueFilter... filters) {
        this.filters = filters;
    }

    @Override
    public Object apply(Object object, String name, Object value) {
        if (ArrayUtil.isEmpty(filters)) {
            return value;
        }
        for (ValueFilter filter : filters) {
            value = filter.apply(object, name, value);
        }
        return value;
    }
}
